/*
 * @Author: 脉迈
 * @Date: 2021-10-21 18:18:12
 * @LastEditors: 脉迈
 * @LastEditTime: 2021-10-27 18:36:04
 */

import React,{useRef,useEffect} from "react";
import "./blockText.css";
interface textProps {
  text: string;
  color?: string;
  font: object;
  style: any;
  onChange:any;
}

const BlockText = (props: textProps) => {
  const style = props.style;
  let newStyle: any = {};

  for (const key in style) {
    if (Object.prototype.hasOwnProperty.call(style, key)) {
      newStyle[key] = style[key]["value"];
    }
  }
  return <p className="text" suppressContentEditableWarning contentEditable={true} style={{ ...props.font, ...newStyle }} onInput={(e: any)=>{props.onChange(e.target.innerText)}}>{props.text}</p>;
};

export default BlockText;
